﻿@using Novagoal.Website.Models.Views
@using Novagoal.Website.WebApp.Helpers
@using Novagoal.Utils
@using Ids.Web.Security

@model PartiesViewModel
@{
    ViewBag.Title = string.Format("Novagoal | {0} Party", Model.Party.Id == 0 ? "Add" : "Edit");
    Layout = "~/Views/Shared/MasterLayout.cshtml";
}
@section PageContent {
    <script src="@Url.Content("~/Scripts/novagoal-parties.js")" type="text/javascript"></script>
    <div class="main-content ui-corner-top">
        <div class="ui-widget-header ui-corner-all">
            <div class="title">@string.Format("{0} Party", Model.Party.Id == 0 ? "Add" : "Edit")</div>
        </div>
        @{Html.RenderPartial("SubmitResults"); }
        <div class="ui-widget-content ui-corner-bottom">
            @using (Html.BeginForm("Save", "Parties", FormMethod.Post, new { id = "partyForm", enctype = "multipart/form-data" }))
            {
                <input type="hidden" id='PartyId' name='PartyId' value='@Model.Party.Id' />
                <fieldset class='formContent'>
                <legend>Party Information</legend>
                    <div class='formColumn'>
                        @Html.Label("Tournament *")
                        @{var tournamentId = Model.Party.Tournament != null ? Model.Party.Tournament.Id : 0;}                  
                        @Html.DropDownList("TournamentId", new SelectList(Model.Tournaments, "Id", "Name", tournamentId), "Select one")
                    </div>
                    <div class='formColumn'>
                        @Html.Label("Name *")
                        @Html.TextBox("Name", Model.Party.Name)
                    </div>
                </fieldset>
                
                <fieldset class="formContent">
                    <legend>Members</legend>
                    <div>
                    @Html.Label("Add member")
                    @Html.DropDownList("PeopleList", new SelectList(Model.People, "Id", "FullName"), "Select one")
                    <input type="button" onclick="AddMember()" value="Add" />
                    <ul id="MembersList">
                        @foreach (var person in Model.Members)
                        {
                            <li>@person.FullName</li>
                            @Html.Hidden("MemberId", person.Id)
                        }
                    </ul>
                    </div>
                </fieldset>
                
                <br />
                <div style='text-align:center'>
                    <label for="submit"></label>
                    <input type="submit" value="Save" class='button' />
                </div>
            }
        </div>
    </div>
}
